package org.sen.action;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.sen.service.impl.AjaxDemoServiceImpl;
import org.sen.utils.PublicUtils;

import com.alibaba.fastjson.JSON;

/**
 * Servlet implementation class QueryComment
 */
@WebServlet("/QueryComment")
public class QueryComment extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * 获取评论区域内容
	 * 
	 */
	protected void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		// 获取评论内容数据
		org.sen.bean.ComentBean adminB = PublicUtils.convertFormData2Bean(request, org.sen.bean.ComentBean.class);
		List<org.sen.bean.ComentBean> lstAdmins = PublicUtils.getInstance(AjaxDemoServiceImpl.class).queryLoginInfoByParams(adminB);
		//System.out.println("查询结果：" + lstAdmins);
		// 借助第三方的工具将集合转换为json字符串【alibaba的fastjson插件包】
		// 将查询结果集list转换为json字符串
		String strJson = JSON.toJSONStringWithDateFormat(lstAdmins, "yyyy-MM-dd HH:mm:ss");
		// ajax响应
		// 响应客户单的请求
		PrintWriter pw = response.getWriter();
		// 将json字符串发回客户端浏览器
		pw.write(strJson);
		pw.flush();
		pw.close();
	}

}
